package br.edu.utfpr.backupTools.util.worker;

import javax.swing.SwingWorker;

import br.edu.utfpr.backupTools.controller.ControladorBackupImpl;
import br.edu.utfpr.backupTools.controller.interfaces.ControladorBackup;
import br.edu.utfpr.backupTools.controller.validator.BackupValidator;
import br.edu.utfpr.backupTools.model.dao.DaoBackupImpl;
import br.edu.utfpr.backupTools.model.dao.interfaces.DaoBackup;
import br.edu.utfpr.backupTools.model.pojo.Backup;
import br.edu.utfpr.backupTools.util.enums.Acao;
import br.edu.utfpr.backupTools.view.action.AbstractCommand;
import br.edu.utfpr.backupTools.view.action.backup.GerarBackupIndividual;
import br.edu.utfpr.backupTools.view.action.backup.GerarTodosBackups;
import br.edu.utfpr.backupTools.view.action.strategy.Control;
import br.edu.utfpr.comum.RetornoValidacao;

import java.util.List;

/**
 * Worker responsável por fazer backup individual e geral
 * 
 * @author Luan Malaguti Reffatti
 *
 */
public class WorkerBackup extends SwingWorker<Void, Void> {
	
	private Backup backup;
	private RetornoValidacao rv;

	public WorkerBackup(Backup backup)
	{
		this.backup = backup;
	}
	
	@Override
	protected Void doInBackground() throws Exception
	{
        if(backup == null){
            rv = Control.getInstance().command().get(Acao.GERAR_TODOS_BACKUPS).execute(null);
		}
		else{
            rv = Control.getInstance().command().get(Acao.GERAR_BACKUP_INDIVIDUAL).execute(backup);
		}
		return null;
	}
	
	public RetornoValidacao getRv(){
		return rv;
	}
}